﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/tld/struts-html" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tld/jstl/c" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/jstl/fn" prefix="fn" %>
<%@ taglib uri="/WEB-INF/tld/FCKeditor" prefix="FCK" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
  <head>
    <html:base />
    
    <title>添加资讯</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
.vb_wid {width:100%; margin: 0 auto; border-top:1px #FDB18D solid; background:#F5F5F5; color:#FE6500; text-indent:20px; line-height:25px; font-size:12px;}
.fb_search {width:90%; margin:0 auto; margin-top:20px; border:1px #FFCD7F solid;}
.fb_search h1 {background:#FFEFBB; margin:0px; padding:0px; line-height:28px; text-indent:10px; font-size:14px;}
.fb_ddd {width:90%; margin:0 auto; margin-top:10px; border-top:3px #FFCC00 solid; background:url(images/pen.gif) no-repeat 5px 3px; height:40px; text-indent:50px; line-height:40px; color:#464646; font-size:12px;}
.fb_nr {width:90%; margin:0 auto; margin-top:10px; line-height:40px; font-size:12px; color:#464646}
.fb_nr span {color:#CCC;}
.fb_nr select {color:464646; font-size:12px;}
.fb_nr Div {margin-left:10px;}
.fb_nr .table11 {border-top:1px #FFCC66 solid; background:#FFF2D7;}
.fb_nr .table22 {border-top:1px #E1E1E1 solid; background:#F9F9F9; margin-left:10px;}
.fb_nr .table33 {border-top:1px #FFCC66 solid; border-bottom:1px #FFCC66 solid; background:#FFF2D7;}
.fb_nr .table44 {border-top:1px #E1E1E1 solid; border-bottom:1px #E1E1E1 solid; background:#F9F9F9; margin-left:10px;}
.inputtttt {border:1px #DEA303 solid; height:20px; color:#464646; font-size:12px; background:url(images/bottom_bg.jpg) repeat-x left top;}
</style>
	<script type='text/javascript' src='/dwr/interface/homeSiteDWRServ.js'></script>
<script type='text/javascript' src='/dwr/engine.js'></script>
<script type='text/javascript' src='/dwr/util.js'></script>
<script type="text/javascript">
 function check(){
  var title=document.getElementById('title').value;
  var source=document.getElementById('source').value;
  var keyword=document.getElementById('keyword').value;
  var writer=document.getElementById('writer').value;
  var imgstr=document.getElementById('imgstr').value;
     if(title==null||title==''){
          alert('资讯标题不可以为空！！！');
          return false;
     }
     if(title.length>30){
          alert('资讯标题不可以大于30个字符！！！');
          return false;
     }
     if(keyword==null||keyword==''){
          alert('关键字不可以为空！！！');
          return false;
     }
     if(keyword.length>25){
          alert('关键字不可以大于25个字符！！！');
          return false;
     }
     if(writer==null||writer==''){
          alert('作者不可以为空！！！');
          return false;
     }
     if(writer.length>25){
          alert('作者不可以大于25个字符！！！');
          return false;
     }
    if(source.length>25){
          alert('来源不可以大于25个字符！！！');
          return false;
     }

  for(var i=0;i<document.all.isImg.length;i++){
  	if(document.all.isImg[i].checked&&document.all.isImg[i].value=='1') {
  	  var imgstr=document.getElementById('imgstr').value;
  	   if(imgstr==null||imgstr==""){
  	      alert('图片新闻，请上传图片！！！');
  	      return false;
  	   }
  	   for(var i=0;i<document.all.isImgSmallTitle.length;i++){
  	    if(document.all.isImgSmallTitle[i].checked&&document.all.isImgSmallTitle[i].value=='1') {
  	         var imgTitle=document.getElementById("imgTitle").value;
  	           	   if(imgTitle==null||imgTitle==""){
  	               alert('标题新闻，请填写小标题！！！');
  	               return false;
  	   }
  	           	   if(imgTitlelength>25){
  	               alert('小标题不可以大于25个字符！！！');
  	               return false;
  	   }
  	   }
  	   
  	   }

			  		
	 }
  
  }
    for(var i=0;i<document.all.isOutLink.length;i++){
  	if(document.all.isOutLink[i].checked&&document.all.isOutLink[i].value=='1') {
  	  var outLink=document.getElementById('outLink').value;
  	   if(outLink==null||outLink==""){
  	      alert('启用外部链接，填写链接！！！');
  	      return false;
  	   }	  		
	 }
  
  }
     
     
     
     
    return true;
 }
</script>
<script type="text/javascript">
         function fillResult(fillObj,defaultValue,defaultText){
            if(fillObj!=null){
               for(var j=0;j<fillObj.options.length;j++){
                 var option=fillObj.options[j];
                 alert(option.text);
                 fillObj.remove(option);
               }
            }
            fillObj.add(new Option(defaultText,defaultValue));
            
         }

          function getChild1(obj,obj2){
            if(obj.value!='-1'){
               getChildren1(obj.value,obj2); 
            }else{
              var second = document.getElementById("homeSiteNewsClassSid");
		      DWRUtil.removeAllOptions(second.options);
		      DWRUtil.addOptions(second, {'-1':'请选择'});
		      //fillResult(second, '-1','请选择');
		     
		      var third = document.getElementById("homeSiteNewsClassThid");
		      DWRUtil.removeAllOptions(third.options);
		      DWRUtil.addOptions(third, {'-1':'请选择'});
		      //fillResult(third, '-1','请选择');
            }
		     
	 	}
	 	var typeId;
	 	var parId;
		function getChildren1(parId,typeId){
             //通过类型id和父类id获取Map列表
			homeSiteDWRServ.loadSecondHomeSiteNewsClassByType(typeId,parId,getSecondProList);
		}
	 
	    function getSecondProList(data){
	    
	  	  var second = document.getElementById("homeSiteNewsClassSid");
	      DWRUtil.removeAllOptions(second);
	      DWRUtil.addOptions(second, {'-1':'请选择'}); 
	      DWRUtil.addOptions(second, data);
	    }
 
 	  //通过二级分类id,获取三级分类列表  第一个参数值,第二个参数类型值
 	  function loadThirdSelectList(obj,obj2)
 	  {
 	      var parId = obj.value;
 	      var typeId = obj2;
 	      
 	      if(parId!='-1'){
 	      homeSiteDWRServ.loadSecondHomeSiteNewsClassByType(typeId,parId,setThirdSelectList);
 	      }else{
 	      
  	          var second = document.getElementById("homeSiteNewsClassThid");
		      DWRUtil.removeAllOptions(second.options);
		      DWRUtil.addOptions(second, {'-1':'请选择'});
 	      }
 	      
 	      
 	  }
 	  
 	  //设置三级分类
 	  var data;
 	  function setThirdSelectList(data)
 	  {
 	      var second = document.getElementById("homeSiteNewsClassThid");
	      DWRUtil.removeAllOptions(second);
	      DWRUtil.addOptions(second, {'-1':'请选择'});
	      DWRUtil.addOptions(second, data);
 	  }
 	  
 	  
 		function getChild2(obj2){
 		var obj_City = document.getElementById("homeSiteNewsClassSid");
    		
    		var scLabel="";
    		var scList=obj_City.options;
    		for(var j=0;j<scList.length;j++)
    		{
    		    if(scList[j].selected )
    		    {
    		    
    		       scLabel=scList[j].text;
    		    }
    		}
    		 var obj_County = document.getElementById("homeSiteNewsClassThid");

    		var city_Index = obj_City.selectedIndex;
    		var city_Value = obj_City.options[city_Index].value;
    		if(city_Value != "" && city_Value != null&&city_Value!=-1){
    		    getChildren2(city_Value,obj2);
    		}else{
    			DWRUtil.removeAllOptions(obj_County);
				DWRUtil.addOptions(obj_County,{'-1':'请选择'});
    		}
	 	}
		  function getChildren2(parId,obj2){
			homeSiteDWRServ.loadNewsClassList(parId,obj2,getThirdProList);
		 }
	     function getThirdProList(data){
		  	  var third = document.getElementById("homeSiteNewsClassThid");
		      DWRUtil.removeAllOptions(third);
		      DWRUtil.addOptions(third, {'-1':'请选择'}); 
		      DWRUtil.addOptions(third, data,'id','names'); 
	     }
		

    function change(){
     var imgstr1=document.getElementById("imgstr1");
     var imgstr=document.getElementById("imgstr");
     var isImgSmallTitlestr=document.getElementById("isImgSmallTitlestr");
     var imgTitlestr=document.getElementById("imgTitlestr");
     var imgTitle=document.getElementById("imgTitle");
    for(var i=0;i<document.all.isImg.length;i++){
			 if(document.all.isImg[i].checked&&document.all.isImg[i].value=='0') {
			  		imgstr1.style.display="none";
			  		imgstr.disabled = true;
			  		isImgSmallTitlestr.style.display="none";
			  		imgTitle.disabled=true;
			  		
			 for(var i=0;i<document.all.isImgSmallTitle.length;i++){
			 if(document.all.isImgSmallTitle[i].value=='0') {
			  		document.all.isImgSmallTitle[i].checked='true';
			 }

			
	}
			  		
			  		imgTitlestr.style.display="none";
			  		
			 }
			 if(document.all.isImg[i].checked&&document.all.isImg[i].value=='1') {
			  		imgstr1.style.display="block";
			  		imgstr.disabled = false;
			  		isImgSmallTitlestr.style.display="block";
			  		imgTitle.disabled=false;
			  		
			 }
			
	}
  }
    function change1(){
     var imgTitlestr=document.getElementById("imgTitlestr");
    for(var i=0;i<document.all.isImgSmallTitle.length;i++){
			 if(document.all.isImgSmallTitle[i].checked&&document.all.isImgSmallTitle[i].value=='0') {
			  		imgTitlestr.style.display="none";
			 }
			 if(document.all.isImgSmallTitle[i].checked&&document.all.isImgSmallTitle[i].value=='1') {
			  		imgTitlestr.style.display="block";
			 }
			
	}
  }
  
  
  
   function changelink(){
     var outLinkStr=document.getElementById("outLinkStr");
     var outLink=document.getElementById("outLink");
    for(var i=0;i<document.all.isOutLink.length;i++){
			 if(document.all.isOutLink[i].checked&&document.all.isOutLink[i].value=='0') {
			  		outLinkStr.style.display="none";
			  		outLink.disabled = true;
			 }
			 if(document.all.isOutLink[i].checked&&document.all.isOutLink[i].value=='1') {
			  		outLinkStr.style.display="block";
			  		outLink.disabled= false;
			 }
			
	}
  }


</script>


  </head>
<body>
<logic:present name="add">
<bean:write name="add" filter="false"/>
</logic:present>
<div class="fb_ddd">添加资讯</div>
<div class="fb_nr">
    <html:form action="/admin/homeSite/homeSiteNews.do?action=add" onsubmit="return check();" enctype="multipart/form-data">
     <table width="100%" border="0">
      <td width="17%" align="center" class="table11">资讯分类:</td>
      <td width="83%" class="table22"><div><label>
    <html:select property="homeSiteNewsClassBid" onchange="getChild1(this,'${bmClassTypeId}');">
    <html:option value="-1" >请选择</html:option>
    <logic:present name="listSiteNewsBClass">
    <logic:iterate id="item" name="listSiteNewsBClass">
    <option value="${item.id }" <c:if test="${homeSiteNewsClassBid==item.id }">selected</c:if>>${item.names}</option>
    </logic:iterate>
    </logic:present>
    </html:select>-
    <html:select property="homeSiteNewsClassSid" onchange="loadThirdSelectList(this,'${bmClassTypeId}');">
    <html:option value="-1" >请选择</html:option>
    <logic:present name="mapsecond">
    <logic:iterate id="item" name="mapsecond">
    <option value="${item.key }" <c:if test="${homeSiteNewsClassSid==item.key }">selected</c:if>>${item.value}</option>
    </logic:iterate>
    </logic:present>
     </html:select>-
    <html:select property="homeSiteNewsClassThid">
    <html:option value="-1" >请选择</html:option>
    <logic:present name="mapthird">
    <logic:iterate id="item" name="mapthird">
    <option value="${item.key }" <c:if test="${homeSiteNewsClassThid==item.key }">selected</c:if>>${item.value}</option>
    </logic:iterate>
    </logic:present>
    </html:select> </label></div></td>
	</tr>
	 <tr>
      <td align="center" class="table11">新闻标题:</td>
      <td class="table22"><div><label>
         <input type="text" name="title" class="cpxx_int" size="50" value="${title}"/><font color="red">*</font>
         </label></div></td>
       </tr>
	 <tr>
      <td align="center" class="table11">关 键 字:</td>
      <td class="table22"><div><label>
         <input type="text" name="keyword" class="cpxx_int" size="18" value="${keyword}"/><font color="red">*</font>
        <span>(多个关键字间用&quot;,&quot;逗号隔开)</span></label></div></td>
       </tr>
       

	 <tr>
      <td align="center" class="table11">资讯作者:</td>
      <td class="table22"><div><label>
         <input type="text" name="writer" class="cpxx_int" size="18" value="wsj"/><font color="red">*</font>
         </label></div></td>
       </tr>
	 <tr>
      <td align="center" class="table33">资讯来源:</td>
      <td class="table44"><div><label>
         <input type="text" name="source" class="cpxx_int" size="18"  value="http://www.wsj.com"/><font color="red">*</font><span>(比如:http://www.google.com)</span>
          <html:hidden property="isDel" value="0"/></div></td>
       </tr>
       <tr>
       <td align="center" class="table33">是否推荐：</td>
      <td class="table44"><div><label>
          <input type="radio" name="iscommend" value="0" />否 
          <input type="radio" name="iscommend" value="1" checked />是</label></div></td>
       </tr>
       <tr>
      <td align="center" class="table11">是否热点新闻:</td>
      <td class="table22"><div><label>
          <input type="radio" name="hotspot" value="0" />否 
          <input type="radio" name="hotspot" value="1" checked />是</label>
          </label></div></td>
       </tr>
       <tr>

       <td align="center" class="table11">是否审核</td>
      <td class="table22"><div><label>
         	<html:radio property="audite" value="0" >否</html:radio>
			<html:radio property="audite" value="1" >是</html:radio></label></div></td>
       </tr>
       <tr>
      <td align="center" class="table11">图片新闻：</td>
      <td class="table22"><div><label>
            <input type="radio"  name="isImg" value="0" onclick="change();" checked />否
			<input type="radio"  name="isImg" value="1" onclick="change();" />是
         </label></div></td>
       </tr>
       <tr id="imgstr1" style="display:none;">
        <td align="center" class="table11">图片：</td>
        <td class="table22"><div><label>
         <input type="file" name="imgstr" />
         </label></div></td>
       </tr>
       <tr id="isImgSmallTitlestr" style="display:none;">
        <td align="center" class="table11">图片小标题</td>
        <td class="table22"><div><label>
         	<input type="radio" name="isImgSmallTitle" value="0" onclick="change1();" checked />否
			<input type="radio" name="isImgSmallTitle" value="1" onclick="change1();" />是</label></div></td>
       </tr>
       <tr id="imgTitlestr" style="display:none;">
         <td align="center" class="table11">小标题</td>
         <td class="table22"><div><label>
         <input type="text" name="imgTitle" /><font color="red">*</font>
        </label></div></td>
       </tr>
       
     <tr>
      <td align="center" class="table11">外部链接：</td>
      <td class="table22"><div><label>
            <input type="radio"  name="isOutLink" value="0" onclick="changelink();" checked />否
			<input type="radio"  name="isOutLink" value="1" onclick="changelink();" />是
         </label></div></td>
       </tr>
       <tr id="outLinkstr" style="display:none;">
        <td align="center" class="table11">链接：</td>
        <td class="table22"><div><label>
         <input type="text" name="outLink" /><font color="red">*(http://www.google.cn)</font>
         </label></div></td>
       </tr>
       
       
       
             <tr>
             
        <td align="center" class="table11">资讯内容：</td>
        <td class="table22"><div><label></label></div></td>
	</tr>
					    
	 <tr>
		<td colspan="2">
			<FCK:editor 
			id="content" 
			basePath="/FCKeditor/" 
			width="609" 
			height="593" 
			skinPath="/FCKeditor/editor/skins/silver/" 
			toolbarSet = "Default">${content}
			</FCK:editor> 
	   </td>
	 </tr>
	 
	   <tr>
         <td></td>
         <td><label>
           <input type="submit" name="Submit" value="提交" class="cpxx_int1" />
           <input type="reset" name="Submit2" value="重置" class="cpxx_int1" />
         </label>
         
         </td>
       </tr>
     </table>
         </html:form>
   <h1><img src="image/qqddc_shop1.gif" width="720" height="8" /></h1>
</div>
</body>
</html:html>
